package com.baidu.mpks.role.service;

import com.baidu.mpks.permission.domain.PermissionDataRole;
import com.baidu.mpks.permission.dto.TreePermissionDto;
import com.baidu.mpks.permission.dto.TypePermissionDto;
import com.baidu.mpks.role.domain.Role;
import com.baidu.mpks.role.domain.RolePermission;
import com.baidu.mpks.role.dto.RoleDto;
import org.apache.poi.ss.usermodel.Workbook;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;

public interface RoleService {

    List<Role> findByUserId(String userId);

    Set<Integer> findRoleIdsByUserId(String userId);

    Set<String> findStringRoleIdsByUserId(String userId);

    Set<String> findRoleNamesByUserId(String userId);

    Map<String, Object> getRoleList();

    List<Role> findRoleUserList(Integer pageNum, Integer pageSize);

    List<Role> findRoleList();

    void updateRole(Role role);

    void updateRoleStatus(Role role);

    void addRoleOrUser(Integer roleId, String userId);

    void deleteDataAndFuncPermissionByRoleId(Integer roleId);

    void deleteRoleOrUserByRoleId(Integer roleId);

    boolean isExistRoleUser(Integer roleid, String userId);

    void deleteRole(Role role);

    Role findById(int id);

    List<RolePermission> findByPermissionCode(String permissionCode);

    List<Role> findByGroupIdAndRoleIdIn(Set<Integer> roleIdList);

    int findRoleUserByUserIdAndRoleId(String userId, Set<Integer> roleIds);

    Map<String, Object> getRoleListPage(Integer pageNum, Integer pageSize, String keyword);

    List<Role> findRoleListPage(Integer pageNum, Integer pageSize, String keyword);

    void addRoleAndPermission(Role role, List<Integer> permissionList, List<TreePermissionDto> treeList, List<TypePermissionDto> typeList);

    void updateRoleAndPermission(Role role, List<Integer> permissionList, List<TreePermissionDto> treeList, List<TypePermissionDto> typeList);

    void addDataPermission(Role role, List<TreePermissionDto> treeList, List<TypePermissionDto> typeList);

    RoleDto findDataPermissionInfoByRoleId(int roleId);

    Map<String, TreePermissionDto> addTreeOpTypeList(Set<PermissionDataRole> oriTreePermissionList);

    Map<String, TypePermissionDto> addTypeOpTypeList(Set<PermissionDataRole> oriTypePermissionList);

    void exportDataToWorkbook(Workbook workbook);

    void downWorkBookToPC(HttpServletResponse response, Workbook workbook, String fileName) throws IOException;

    List<Role> findByIds(List<Integer> roleIds);

    String formatRoleAndPermissionInfoForAuditLog(Integer roleId);
}
